﻿using System;
using System.Collections.Generic;
using System.Text;

using Torch.WL.DataAccess.CleanChina;
using Torch.WL.Entity.CleanChina;
using Torch.FrameWork.Utility;

namespace Torch.WL.Business.CleanChina
{
    class TbExpoManager
    {
        private readonly TbExpoAccess dal = new TbExpoAccess();
        public TbExpoManager()
        { }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TbExpoEntity GetModel(int expoId)
        {

            return dal.GetModel(expoId);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        public TbExpoEntity GetModelByCache(int expoId)
        {

            string CacheKey = "TbExpoEntityModel-" + expoId;
            object objModel = DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(expoId);
                    if (objModel != null)
                    {
                        int ModelCache = ConfigHelper.GetConfigInt("EntityCacheMinutes");
                        DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (TbExpoEntity)objModel;
        }




    }
}
